from selenium import webdriver
import  time

from selenium.webdriver.common.by import By

we=webdriver.Chrome()
url='https://www.baidu.com'
we.get(url)
element=we.find_element(By.ID,'su')
print(element.get_attribute('value'))
element=we.find_element(By.NAME,'tn')
print(element.get_attribute('value'))
time.sleep(3)
# we.close()
element2=we.find_element(By.CLASS_NAME,'s_btn')
print(element2.get_attribute('value'))
element3=we.find_elements(By.TAG_NAME,'input')
for i in element3:
    print(i.get_attribute('value'))
element4=we.find_element(By.LINK_TEXT,'新闻')
print(element4.text)
print(element4.get_attribute('href'))
element5=we.find_element(By.PARTIAL_LINK_TEXT,'新')
print(element5.text)
print(element5.get_attribute('herf'))
element6=we.find_element(By.XPATH,'//*[@id="su"]')
print(element6.get_attribute('value'))
element7=we.find_element(By.CSS_SELECTOR,'#su')
print(element7.get_attribute('value'))
we.close()


